#pragma once
#ifndef Vector_CPP 
#define Vector_CPP
#include <math.h>


float _dot(float* l,float* r,int num);
void _cross(float* l,float* r,float* ret);
class Vec2
{
public:
	Vec2(float x = 0,float y = 0);
	~Vec2(void);
	float x,y;
	float& operator[](int i){return ((float*)(&x))[i];};
	void operator=(Vec2& r){x=r.x;y=r.y;};
	float dot(Vec2& r){return _dot(&this->x,&r.x,2);};
};
class Vec3:public Vec2
{
public:
	Vec3(float x = 0,float y = 0,float z = 0);
	Vec3(Vec2& vec2,float z = 0);
	~Vec3();
	float z;
	void operator=(Vec3& r){x=r.x;y=r.y;z=r.z;};
	void operator+=(Vec3& r){x+=r.x;y+=r.y;z+=r.z;};
	Vec3 operator+(Vec3& r){return Vec3(x+r.x,y+r.y,z+r.z);};
	Vec3 operator-(Vec3& r){return Vec3(x-r.x,y-r.y,z-r.z);};
	void operator/=(float r){x/=r;y/=r;z/=r;};
	float length(){return sqrtf(x*x+y*y+z*z);};
	float dot(Vec2& r){return _dot(&this->x,&r.x,3);};
	Vec3 cross(Vec3& r){Vec3 v;_cross(&this->x,&r.x,&v.x);return v;};
};
class Mat4;
class Vec4:public Vec3
{
public:
	Vec4(float x = 0,float y = 0,float z = 0,float w = 0);
	~Vec4();
	float w;
	Vec4 operator*(Mat4* m);
	void operator=(Vec4& r){x=r.x;y=r.y;z=r.z;w=r.w;};
	float dot(Vec2& r){return _dot(&this->x,&r.x,4);};
};

#endif
